﻿using System;

class NoOfTimesNumberAppears

            // Write a method that counts how many times given number appears in given array. Write a test program to check if the method is working correctly.
{
    static void Main()
    {
        Console.Write("Enter the size of the array:");
        int arraySize = int.Parse(Console.ReadLine());
        int[] array = new int[arraySize];
        Console.WriteLine();

        Console.WriteLine("Enter the elements of the array:");
        for (int i = 0; i < arraySize; i++)
        {
            array[i] = int.Parse(Console.ReadLine());
        }
        Console.WriteLine();

        Console.Write("Enter the searched number:");
        int searchedNum = int.Parse(Console.ReadLine());
        Console.WriteLine();
        CountForRepetition(array, searchedNum);
    }

    private static void CountForRepetition(int[] array, int searchedNum)
    {
        int count = 0;
        for (int i = 0; i < array.Length; i++)
        {
            if (array[i] == searchedNum)
            {
                count++;
            }
        }
        Console.WriteLine("The number {0} appears {1} times.", searchedNum, count);
    }
}


